search link

Good Afternoon, 

I have a little doubt. 

In a dxl, I'm wrinting a function that sends a message only when this module is linked  only to another specific module and that the attribute Type is with a specific option. 
To this end, I made the dxl part below, but now the dxl sends me the warning message in any situation, something tells me that  the logic might be wrong, but I kind of got stuck in that line of reasoning. (see the dxl below)
I'm very wrong in my logic? Or in the function itself?

Thanks!

 

Link sourceLink 
ModName_ sourceMod
bool hasLink = false
 
 
//  for check if the requirement only has link to SOME SPECIFIC MODULE
    for sourceLink in reqmtObj->"Trace to" do {
sourceMod = target sourceLink
    
if(((fullName(sourceMod)!= "-SomeEnd") && (fullName(sourceMod) != "-OtherEnd")) && (reqmtObj."Type" "" != "Help"))  {
hasLink = true
}
 
   if(hasLink){
warningBox("The message that should appear")
}
}

braolive - Fri Mar 14 16:40:03 EDT 2014

Re: search link
GregM_dxler - Sat Mar 15 09:38:19 EDT 2014

Hi,

Yes, I think your logic is not quite correct.

In the if check, you are using fullName, which will include the path of the target module and will have slashes in it (/project/folder/module) and so the check for != "-SomeEnd" and != "-OtherEnd" will probably always be true.

I'm assuming reqmtObj must be an object in your current module and not in the target module (at the end of the link).  If it is trying to be an object in the target, then the target module needs to be open first.  If not open, then the object will probably be null, in which case, the last condition would also be true.

Hope this helps,

Greg

Re: search link
Wolfgang Uhr - Sun Mar 16 13:37:51 EDT 2014

Hello

I think it is not a good idead to use "reqmtObj."Type" "" != "Help"" inside the if statement. The complexity of the statement is too high for dxl.

Try:

string sReqMtObj = reqmtObj."Type";
if (((fullName(sourceMod)!= "-SomeEnd") && (fullName(sourceMod) != "-OtherEnd")) && (sReqMtObj != "Help"))  {

Best regards

Wolfgang